﻿#include "class_test.h"

using namespace std;

class Box
{
public:
    // 成员函数声明
    double get(void);
    void set(double len, double bre, double hei);
    Box();
    Box(double len, double bre, double hei);
    ~Box();

    double length;   // 长度
    double breadth;  // 宽度
    double height;   // 高度

};
//构造函数
Box::Box() 
{
    cout << "start" << endl;
}
Box::Box(double len, double bre, double hei) :length(len), breadth(bre), height(hei)
{
    cout<<"start init class"<<endl;
}
Box::~Box()
{
    cout << "end" << endl;
}

// 成员函数定义
double Box::get(void)
{
    return length * breadth * height;
}

void Box::set(double len, double bre, double hei)
{
    length = len;
    breadth = bre;
    height = hei;
}

int main()
{
    Box Box1;        // 声明 Box1，类型为 Box
    Box Box2(5,6,7);        // 声明 Box2，类型为 Box
    Box Box3;        // 声明 Box3，类型为 Box
    double volume = 0.0;     // 用于存储体积

    // box 1 详述
    Box1.height = 5.0;
    Box1.length = 6.0;
    Box1.breadth = 7.0;

    // box 1 的体积
    volume = Box1.height * Box1.length * Box1.breadth;
    cout << "Box1 的体积：" << volume << endl;

    // box 2 的体积
    volume = Box2.height * Box2.length * Box2.breadth;
    cout << "Box2 的体积：" << volume << endl;

    // box 3 详述
    Box3.set(16.0, 8.0, 12.0);
    volume = Box3.get();
    cout << "Box3 的体积：" << volume << endl;



    Box b1 = Box(6, 6, 7);

    return 0;
}
